package com.szcinda.service.dto.zadOrder;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public class ZadOrderDto implements Serializable {
    public String id;
    public String clientId;
    public String clientName;
    public String bookName;
    public String orderNumber;
    public String businessId;
    public String businessNumber;
    public String bookNumber;
    public LocalDate pickDate;
    public String pickPlace;
    public int quantity;
    public double volume;
    public String cabinetType;
    public String cabinetNumber;
    public LocalDate preDepartureTime;
    public LocalDate actDepartureTime;
    public String cabinetNumberArr;
    public String originPlace;
    public String destPlace;
    public String carrierId;
    public String carrierName;
    public String userId;
    public String userName;
    public String currency;
    public String goodsName;
    public String goodsDetailName;
    public Double goodsWeight;
    public String customsType;
    public LocalDateTime orderArriveTime;
    public LocalDateTime orderLeaveTime;
    public int orderBeyondDays;
    public LocalDate packageReturnDate;
    public int packageUseDays;

    public String remark;

    private String billRemark;// 账单备注

    public String businessCode;
    public String calculateType;
    public String carrierDeparturePort;
    public String packagePic;
    public String customsFile;
    public String carFile;
    public String packageSolution;
    public String stFile;
    public String preOrderConfirm;
    public String transportOrder;
    public String customsReleaseOrder;
    public LocalDateTime arriveTime;
    public String dskAtbMrn;
    public String aging;

    public String organizationId;
    public String organizationName;

    public String invoice;
    public String settlement;
    public String outInvoice;
    public String outSettlement;
    public LocalDateTime createTime;

    public String status; // 订单状态

    // 报关费 关联费用
    public double homeFee;// 主页费单价
    public double sheetFee;// 续页费单价
    public int homeCount;// 主页数
    public int sheetCount;// 续页数
    public double overFee;// 超期堆存费
    public String overFeeCurrency; // 超期堆存费币种


    public List<FeeDto> feeList = new ArrayList<>();

    public List<FeeDto> outFeeList = new ArrayList<>();

    public List<OrderFollowDto> followDtos = new ArrayList<>();
    public boolean alert;

    public void setAlert(boolean alert) {
        this.alert = alert;
    }

    public boolean getAlert() {
        return alert;
    }

    @Data
    public static class OrderFollowDto implements Serializable {
        public String id;
        public String cabinetNumber;
        public String packagePic;
        public String customsFile;
        public String carFile;
        public String packageSolution;
        public String stFile;
        public String preOrderConfirm;
        public String transportOrder;
        public String customsReleaseOrder;
        public LocalDateTime arriveTime;
        public String dskAtbMrn;
        public String aging;
        public LocalDate remindDate;
    }


    @Data
    public static class FeeDto implements Serializable {
        public String id;
        public String feeName;
        public String status;
        public double feeCount;
        public String currency;
        public boolean canSee;
        public String carrierId;


    }

    public static Map<String, String> getFieldMap() {
        Map<String, String> map = new HashMap<>();
        map.put("订单编号", "orderNumber");
        map.put("所属机构", "organizationName");
        map.put("客户", "clientName");
        map.put("订舱人", "bookName");
        map.put("订舱号", "bookNumber");
        map.put("柜号", "cabinetNumber");
        map.put("业务类型", "businessCode");
        map.put("业务编号", "businessNumber");
        map.put("计费方式", "calculateType");
        map.put("提货日期", "pickDate");
        map.put("提货地点", "pickPlace");
        map.put("数量", "quantity");
        map.put("货物体积(m³)", "volume");
        map.put("柜型", "cabinetType");
        map.put("班列日期", "preDepartureTime");
        map.put("发车日期", "actDepartureTime");
        map.put("起始站", "originPlace");
        map.put("目的站", "destPlace");
        map.put("出境口岸", "carrierDeparturePort");
        map.put("报关方式", "customsType");
        map.put("货物品类", "goodsName");
        map.put("货物品名", "goodsDetailName");
        map.put("货物重量(KG)", "goodsWeight");
        map.put("ATA到达日期", "orderArriveTime");
        map.put("境外提重日期", "orderLeaveTime");
        map.put("超期天数", "orderBeyondDays");
        map.put("创建人", "userName");
        map.put("创建时间", "createTime");
        map.put("订单备注", "remark");
        map.put("账单备注", "billRemark");

        return map;
    }

    public static Map<String, String> getFollowMap() {
        Map<String, String> map = new HashMap<>();
        map.put("装箱图片", "packagePic");
        map.put("报关文件", "customsFile");
        map.put("随车文件", "carFile");
        map.put("装箱方案", "packageSolution");
        map.put("ST文件", "stFile");
        map.put("预录单确认", "preOrderConfirm");
        map.put("运单", "transportOrder");
        map.put("报关放行单", "customsReleaseOrder");
        map.put("到站时间", "arriveTime");
        map.put("DSK/ATB/MRN", "dskAtbMrn");
        map.put("时效", "aging");
        map.put("提醒日期", "remindDate");
        return map;
    }

    public static void main(String[] args)throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();
        TestDto testDto = new TestDto();
        testDto.setSearchType("driver");
        testDto.setPostUrl("http://ip:port/postData");
        TestDto.Item item = new TestDto.Item();
        item.setProvince("甘肃省");
        item.setName("赵爱军");
        item.setIdCard("622425198909141255");
        testDto.getData().add(item);
        String result = objectMapper.writeValueAsString(testDto);
        System.out.println(result);
    }
}
